package com.hacker.highccy.enums;

/**
 * 使用枚举表示常量数据字典
 * @Author:这个程序员有纹身
 * @Date: Created in 22:38 2017\12\26 0026
 */
public enum SeckillStatsEnum {
    SUCCESS(1,"秒杀成功"),
    END(0,"秒杀结束"),
    REPEAT_KILL(-1,"重复秒杀"),
    INNER_ERROR(-2,"系统异常"),
    DATA_REWRITE(-3,"数据串改");

    private int state;

    private String stateInfo;

    SeckillStatsEnum(int state, String stateInfo) {
        this.state = state;
        this.stateInfo = stateInfo;
    }

    public int getState() {
        return state;
    }

    public void setState(int state) {
        this.state = state;
    }

    public String getStateInfo() {
        return stateInfo;
    }

    public void setStateInfo(String stateInfo) {
        this.stateInfo = stateInfo;
    }

    public static SeckillStatsEnum stateOf(int index){
        for (SeckillStatsEnum statsEnum : values()){
            if (statsEnum.getState() == index){
                return statsEnum;
            }
        }
        return null;
    }
}
